package rs.pnv.service;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import rs.pnv.model.BankPartner;
import rs.pnv.repository.BankPartnerRepository;

@Service
@Transactional
public class BankPartnerServiceImpl implements BankPartnerService {
	
	@Resource
	private BankPartnerRepository bankRepository;

	@Override
	public BankPartner save(BankPartner bank) {
		return bankRepository.save(bank);
	}

	@Override
	public BankPartner update(BankPartner bank) {
		return bankRepository.save(bank);
	}

	@Override
	public void delete(Long id) {
		bankRepository.delete(id);
	}

	@Override
	public void delete(String bankId) {
		//BankPartner bank = bankRepository.findByBankId(bankId);
		//bankRepository.delete(bank.getId());
	}

	@Override
	public List<BankPartner> findAll() {
		return bankRepository.findAll();
	}

	@Override
	public BankPartner findById(Long id) {
		return bankRepository.findOne(id);
	}

	@Override
	public BankPartner findByBankId(String bankId) {
		System.out.println("============= findByBankId() u serviceImpl");

		return bankRepository.findByBankId(bankId);
	}

	@Override
	public BankPartner findByBankName(String bankName){
		System.out.println("FIND BY NAME; serviceImpl");
		return bankRepository.findByBankName(bankName);
	}
	
	@Override
	public void search() {
		bankRepository.search();
	}
	
	

}
